cmake_minimum_required(VERSION 3.8)
project(ballistic_solver)

## 设置C++标准为C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

## 编译选项：启用严格警告检查
add_compile_options(-Wall -Werror)

## 导出编译命令
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# --------------------------
#  依赖管理
# --------------------------
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

# --------------------------
#  构建配置（共享库+头文件路径）
# --------------------------

# 生成共享库
ament_auto_add_library(${PROJECT_NAME} SHARED
  src/ballistic_solver_node.cpp  
)

# 指定头文件搜索路径
target_include_directories(${PROJECT_NAME} PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)

# --------------------------
#  组件化节点注册
# --------------------------
rclcpp_components_register_node(${PROJECT_NAME}
  PLUGIN "rm_aim::BallisticSolverNode"  # 插件类名
  EXECUTABLE ${PROJECT_NAME}_node        # 独立运行的节点可执行文件名
)

# --------------------------
#  测试配置
# --------------------------
if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # 排除不需要的lint检查项（与示例保持一致）
  list(APPEND AMENT_LINT_AUTO_EXCLUDE
    ament_cmake_copyright
    ament_cmake_cpplint
    ament_cmake_uncrustify
  )
  ament_lint_auto_find_test_dependencies()
endif()

# --------------------------
#  安装配置（按ROS 2标准安装目录结构）
# --------------------------

# 安装共享库文件（动态库/静态库）
install(TARGETS ${PROJECT_NAME}
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)

# 安装头文件
install(DIRECTORY include/
  DESTINATION include/${PROJECT_NAME}
)

# 安装配置文件和启动文件
install(DIRECTORY
  config
  launch
  DESTINATION share/${PROJECT_NAME}
)

ament_package()